﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SmartPlant.Model.Biz;
using SmartPlant.Model.DbContext;
using SmartPlant.Services.Interfaces;
using SmartPlant.WinCore;
namespace SmartPlant.Services
{
    public class LineService : BaseService, ILineService
    {
        public async Task<List<Line>> GetLinesTreeAsync(decimal proId, decimal plantId)
        {
            var sqlwhere = $"LINE_ID>0 AND ENG_PROJ_ID='0' and plant_id='{plantId}'";
            var select = "LINE_NUM LINENUM,LINE_ID LINEID";
            var orderby = "LINE_NUM";
            string url = $"/api/Project/{proId}/line-api?sqlwhere={sqlwhere}&select={select}&orderby={orderby}";
            var res = await GetAsync<List<Line>>(url);
            return res.data;
        }

        public async Task<Line> GetById(decimal lineId)
        {
            string url = $"/api/Project/{GlobalObject.CurrentProject.ProjId}/line-api/{lineId}";
            var res = await GetAsync<Line>(url);
            return res.data;
        }
    }
}
